package io.github.kimmking.kkconfig.spring;

import io.github.kimmking.kkconfig.repository.KKRepository;
import io.github.kimmking.kkconfig.repository.KKRepositoryChangeListener;
import org.springframework.context.ApplicationContext;

import java.util.Map;
import java.util.Set;

/**
 * Description for this class.
 *
 * @Author : kimmking(kimmking@apache.org)
 * @create 2024/4/19 01:07
 */
public interface KKConfigService extends KKRepositoryChangeListener<Map<String, String>> {

    static KKConfigService getDefault(ApplicationContext applicationContext, ConfigMeta meta) {
        KKRepository repository = KKRepository.getDefault(meta);
        KKConfigServiceImpl configService = new KKConfigServiceImpl(applicationContext, repository.getConfig());
        repository.addChangeListener(configService);
        return configService;
    }

    Set<String> getPropertyNames();
    String getProperty(String name);

}
